<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld"  prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld"  prefix="bean" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tlds/custom-html.tld" prefix="chtml" %>
<%@ taglib uri="/WEB-INF/tlds/struts-template.tld" prefix="template" %>

<%@ page import="com.erp.app.common.ProjectConstants"%>
<%@ page import="com.erp.framework.util.CommonUtil" %>
<%@ page import="com.erp.framework.util.user.User" %>
<%@ page import="com.erp.app.common.ProjectConstants" %>
<%@ page import="java.util.Hashtable" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Collection" %>
<%@ page import="com.erp.app.util.web.WebUtil" %>
<%@ page import="com.erp.framework.util.mainmenu.MenuGroup" %>
<%@ page import="com.erp.framework.util.mainmenu.MenuGroupDelegate" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.erp.framework.util.mainmenu.MenuObject" %>
<%@ page import="com.erp.app.common.ProjectConstants" %>
<%@ page import="com.erp.app.login.web.MainMenuAction" %>
<%@ page import="com.erp.app.login.taskAlert.vo.TaskAlertVo"%>
<%@ page import="com.erp.app.login.todoList.vo.TodoListVo"%>

<jsp:useBean id="mainMenuForm" scope="session" type="com.erp.app.login.web.MainMenuForm" />

<!-- NEVER call doLoad() function here, call it via its root parent jsp  -->

<script>
	function doSubmitListForm(action) {
		document.listForm.pageEvent.value = action;
		document.listForm.submit();
	}
</script>

<%
User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

/*
MenuGroupDelegate menuDg = new MenuGroupDelegate();
ArrayList menuList = menuDg.getMenuGroupListByModule(editingUser.getCompanyCode(), editingUser.getUserId(), ProjectConstants.PARENT_MENU_ALERT_LIST);
*/

ArrayList alertList = mainMenuForm.getAlertList();
pageContext.setAttribute("alertList", alertList);
/*
System.out.println("@@@@@@@@@@@@@@JSP, size of alertList=" + alertList.size());
for(int i = 0; (alertList != null) && (i < alertList.size()); i++){
	TaskAlertVo vo = (TaskAlertVo)alertList.get(i);
	System.out.println("@@@@@@@@@@@@@JSP, taskCode = " + vo.getTaskCode());
}
*/

ArrayList todoList = mainMenuForm.getTodoList();
pageContext.setAttribute("todoList", todoList);
/*
System.out.println("@@@@@@@@@@@@@@JSP, size of todoList=" + todoList.size());
for(int i = 0; (todoList != null) && (i < todoList.size()); i++){
	TodoListVo vo = (TodoListVo)todoList.get(i);
	System.out.println("@@@@@@@@@@@@@JSP, todoCode = " + vo.getTodoCode());
}
*/
%>


<form name="listForm" method="POST" action="/EdalWeb/mainMenu.do">
<input type="hidden" name="pageEvent">

	<table border=0 cellpadding=0 cellspacing=0 width=80%>
		<tr>
			<% if(MainMenuAction.TODO_LIST.equals(CommonUtil.nullToString(mainMenuForm.getShowSideList()))) { %>
			<td class="tabtopleftdown">&nbsp;</td>
			<td valign=center width=100 height=30 align=left background="images/menu/enq_down_center.png" nowrap>
				<img src="images/menu/icon_tab_to-do.gif" border=0 width=32 height=26/>
				<font size=1 face=arial>
				<b>TODO</b></font>
			</td>
			<td class="tabtoprightdown">&nbsp;</td> 

			<% } else {%>
			<td class="tabtopleftout">&nbsp;</td>
			<td valign=center width=100 height=30 align=left background="images/menu/enq_out_center.png" nowrap>
				<img src="images/menu/icon_tab_to-do.gif" border=0 width=32 height=26/>
				<font size=1 face=arial>
					<a href="javascript:doSubmitListForm('actionShowToDoList');" class='enq_link'>TODO</a>
				</font>
			</td>
			<td class="tabtoprightout">&nbsp;</td>
			<% } %>

			<% if(MainMenuAction.ALERT_LIST.equals(CommonUtil.nullToString(mainMenuForm.getShowSideList()))) { %>
			<td class="tabtopleftdown">&nbsp;</td>
			<td valign=center width=100 height=30 align=left background="images/menu/enq_down_center.png" nowrap>
				<img src="images/menu/icon_tab_alerts.gif" border=0 width=32 height=26/>
				<font size=1 face=arial>
				<b>ALERT</b></font>
			</td>
			<td class="tabtoprightdown">&nbsp;</td> 

			<% } else {%>
			<td class="tabtopleftout">&nbsp;</td>
			<td valign=center width=100 height=30 align=left background="images/menu/enq_out_center.png" nowrap>
				<img src="images/menu/icon_tab_alerts.gif" border=0 width=32 height=26/>
				<font size=1 face=arial>
				<a href="javascript:doSubmitListForm('actionShowAlertList');" class='enq_link'>ALERT</a></font>
			</td>
			<td class="tabtoprightout">&nbsp;</td>
			<% } %>			

		</tr>
		<tr>
			<td colspan=6>
			<% if(MainMenuAction.ALERT_LIST.equals(CommonUtil.nullToString(mainMenuForm.getShowSideList()))) { %>
				<table class='outline-table' width="100%"  border="0" cellspacing="0" cellpadding="0">
			
				<tr>
					<th class="outline-th">
						&nbsp
					</th>
					<th class="outline-th" nowrap>
<!--						<font size=2 face="arial"><bold>-->
						Task Code
<!--						</bold></font>-->
					</th>
					<th class="outline-th" nowrap>
<!--						<font size=2 face="arial"><bold>-->
						Task Name
<!--						</bold></font>-->
					</th>
					<th class="outline-th" nowrap>
<!--						<font size=2 face="arial"><bold>-->
						Status
<!--						</bold></font>-->
					</th>
					<th class="outline-th" nowrap>
<!--						<font size=2 face="arial"><bold>-->
						Priority
<!--						</bold></font>-->
					</th>
				</tr>
				
				<%
				for(int i = 0; (alertList != null) && (i < alertList.size()) && (i < ProjectConstants.MAX_SHORT_DISPLAY); i++){
					TaskAlertVo vo = (TaskAlertVo)alertList.get(i);
//System.out.println("JSP, inside FOR LOOP, getTaskCode = " + vo.getTaskCode());
				%>
				<tr class="row_action_default" onmouseover="mouseOverHighlight(event,'row_action_hilite')" onmouseout="mouseOutHighlight('row_action_default')" >
					<td class="outline-td">
					<%if(ProjectConstants.PRIORITY_URGENT.equals(vo.getPriority())){%>
						<img src="images/menu/urgent.gif" border=0 width=20 height=20/>
					<%} else {%>
						&nbsp;
					<%}%>
					</td>
					<td class="outline-td">
<!--						<a href='#' class=side_link><font size=1 face="arial">-->
						<%=CommonUtil.nullToString(vo.getTaskCode())%>&nbsp;
<!--						</font></a>-->
					</td>
					<td class="outline-td">
						<acronym title="<%=CommonUtil.nullToString(vo.getTaskDesc())%>">
<!--						<font size=1 face="arial">-->
						<%=CommonUtil.nullToString(vo.getTaskName())%>&nbsp;
<!--						</font>-->
						</acronym>
					</td>
					<td class="outline-td">
						<%if(ProjectConstants.ALERT_STATUS_ALL.equals(vo.getStatus())){%>
							<img src="images/menu/status_all.gif" border=0 alt="<%=vo.getStatus()%>" width=20 height=20/>
						<%} else if(ProjectConstants.ALERT_OUTSTANDING_OUTSTANDING.equals(vo.getStatus())){%>
							<img src="images/menu/status_outstanding.gif" border=0 alt="<%=vo.getStatus()%>" width=20 height=20/>
						<%} else if(ProjectConstants.ALERT_POSTPONED.equals(vo.getStatus())){%>
							<img src="images/menu/status_postpone.gif" border=0 alt="<%=vo.getStatus()%>" width=20 height=20/>
						<%} else if(ProjectConstants.ALERT_COMPLETED.equals(vo.getStatus())){%>
							<img src="images/menu/status_completed.gif" border=0 alt="<%=vo.getStatus()%>" width=20 height=20/>
						<%} else {%>
							&nbsp;
						<%}%>
					</td>
					<td class="outline-td">
						<%if(ProjectConstants.PRIORITY_URGENT.equals(vo.getPriority())){%>
							<img src="images/menu/priority_urgent.gif" border=0 alt="<%=vo.getPriority()%>" width=20 height=20/>
						<%} else if(ProjectConstants.PRIORITY_HIGH.equals(vo.getPriority())){%>
							<img src="images/menu/priority_high.gif" border=0 alt="<%=vo.getPriority()%>" width=20 height=20/>
						<%} else if(ProjectConstants.PRIORITY_NORMAL.equals(vo.getPriority())){%>
							<img src="images/menu/priority_normal.gif" border=0 alt="<%=vo.getPriority()%>" width=20 height=20/>
						<%} else if(ProjectConstants.PRIORITY_LOW.equals(vo.getPriority())){%>
							<img src="images/menu/priority_low.gif" border=0 alt="<%=vo.getPriority()%>" width=20 height=20/>
						<%} else {%>
							&nbsp;
						<%}%>
<%--
						<%if(ProjectConstants.PRIORITY_URGENT.equals(vo.getPriority())){%>
						<font color='red'>
						<%}%>
						<font size=1><%=CommonUtil.nullToString(vo.getPriority())%></font>
						<%if(ProjectConstants.PRIORITY_URGENT.equals(vo.getPriority())){%>
						</font>
						<%}%>
--%>
					</td>
				</tr>
				<% } %>

				</table>

			<% } %>

			<% if(MainMenuAction.TODO_LIST.equals(CommonUtil.nullToString(mainMenuForm.getShowSideList()))) { %>
				<table class='outline-table' width="100%"  border="0" cellspacing="0" cellpadding="0">

				<tr>
					<th class="outline-th" >
						&nbsp
					</th>
					<th class="outline-th" nowrap>
<!--						<font size=2 face="arial"><bold>-->
						Todo Code
<!--						</bold></font>-->
					</th>
					<th class="outline-th" nowrap>
<!--						<font size=2 face="arial"><bold>-->
						Todo Name
<!--						</bold></font>-->
					</th>
					<th class="outline-th" nowrap>
<!--						<font size=2 face="arial"><bold>-->
						Status
<!--						</bold></font>-->
					</th>
					<th class="outline-th" nowrap>
<!--						<font size=2 face="arial"><bold>-->
						Priority
<!--						</bold></font>-->
					</th>
				</tr>		

				<%
				for(int i = 0; (todoList != null) && (i < todoList.size()) && (i < ProjectConstants.MAX_SHORT_DISPLAY); i++){
					TodoListVo vo = (TodoListVo)todoList.get(i);
//System.out.println("JSP, inside FOR LOOP, getTodoCode = " + CommonUtil.nullToString(vo.getTodoCode()));
				%>

				<tr class="row_action_default" onmouseover="mouseOverHighlight(event,'row_action_hilite')" onmouseout="mouseOutHighlight('row_action_default')" >
					<td class="outline-td">
					<%if(ProjectConstants.PRIORITY_URGENT.equals(vo.getPriority())){%>
						<img src="images/menu/urgent.gif" border=0 width=20 height=20/>
					<%} else {%>
						&nbsp;
					<%}%>
					</td>
					<td class="outline-td">
<!--						<a href='#' class=side_link><font size=1 face="arial">-->
						<%=CommonUtil.nullToString(vo.getTodoCode())%>&nbsp;
<!--						</font></a>-->
					</td>
					<td class="outline-td">
						<acronym title="<%=CommonUtil.nullToString(vo.getTodoDesc())%>">
<!--						<font size=1 face="arial">-->
						<%=CommonUtil.nullToString(vo.getTodoName())%>&nbsp;
<!--						</font></acronym>-->
					</td>
					<td class="outline-td">
						<%if(ProjectConstants.TODO_STATUS_ALL.equals(vo.getStatus())){%>
							<img src="images/menu/status_all.gif" border=0 alt="<%=vo.getStatus()%>" width=20 height=20/>
						<%} else if(ProjectConstants.TODO_OUTSTANDING_OUTSTANDING.equals(vo.getStatus())){%>
							<img src="images/menu/status_outstanding.gif" border=0 alt="<%=vo.getStatus()%>" width=20 height=20/>
						<%} else if(ProjectConstants.TODO_POSTPONED.equals(vo.getStatus())){%>
							<img src="images/menu/status_postpone.gif" border=0 alt="<%=vo.getStatus()%>" width=20 height=20/>
						<%} else if(ProjectConstants.TODO_COMPLETED.equals(vo.getStatus())){%>
							<img src="images/menu/status_completed.gif" border=0 alt="<%=vo.getStatus()%>" width=20 height=20/>
						<%} else {%>
							&nbsp;
						<%}%>
					</td>
					<td class="outline-td">
						<%if(ProjectConstants.PRIORITY_URGENT.equals(vo.getPriority())){%>
							<acronym><img src="images/menu/priority_urgent.gif" border=0 alt="<%=vo.getPriority()%>" width=20 height=20/>
						<%} else if(ProjectConstants.PRIORITY_HIGH.equals(vo.getPriority())){%>
							<img src="images/menu/priority_high.gif" border=0 alt="<%=vo.getPriority()%>" width=20 height=20/>
						<%} else if(ProjectConstants.PRIORITY_NORMAL.equals(vo.getPriority())){%>
							<img src="images/menu/priority_normal.gif" border=0 alt="<%=vo.getPriority()%>" width=20 height=20/>
						<%} else if(ProjectConstants.PRIORITY_LOW.equals(vo.getPriority())){%>
							<img src="images/menu/priority_low.gif" border=0 alt="<%=vo.getPriority()%>" width=20 height=20/>
						<%} else {%>
							&nbsp;
						<%}%>
					<%--
						<%if(ProjectConstants.PRIORITY_URGENT.equals(vo.getPriority())){%>
						<font color='red'>
						<%}%>
						<font size=1><%=CommonUtil.nullToString(vo.getPriority())%></font>
						<%if(ProjectConstants.PRIORITY_URGENT.equals(vo.getPriority())){%>
						</font>
						<%}%>
					--%>
					</td>
				</tr>
				<% } %>

				</table>
			<% } %>
			</td>
		</tr>
	</table>

</form>